<template>
	<view class="subsidyMoney">
		<view class="subsidyMoney-head">
			<view class="subsidyMoney-head-title1">
				补助金余额(元)
			</view>
			<view class="subsidyMoney-head-title2">
				<text class="subsidyMoney-head-title2-txt1">{{factoryBalance}}</text>
				<text class="subsidyMoney-head-title2-txt2" @click="cli_topUp">充值</text>
			</view>
		</view>
		<view class="subsidyMoney-main">
			<view class="subsidyMoney-main-title">
				<view class="subsidyMoney-main-title-left">
					<text class="subsidyMoney-main-title-txt1"></text>
					<text class="subsidyMoney-main-title-txt2 font_blod">交易明细</text>
				</view>
				<text class="subsidyMoney-main-title-txt3">只展示最近三个月明细</text>
			</view>
			<view class="subsidyMoney-main-content" v-if="list.length > 0">
				<view class="subsidyMoney-main-content-li" @click="cli_li(item, index)" v-for="(item,index) in list" :key="index">
					<view class="subsidyMoney-main-content-li-left">
						<image v-if="item.factoryType == 4" class="subsidyMoney-main-content-li-left-img"
							src="../../../static/manufacturers/pay_2.png" mode=""></image>
						<image v-else class="subsidyMoney-main-content-li-left-img"
							src="../../../static/manufacturers/pay_1.png" mode=""></image>
					</view>
					<view class="subsidyMoney-main-content-li-cen">
						<view class="subsidyMoney-main-content-li-cen-top">
							<view class="subsidyMoney-main-content-li-cen-top-left">
								{{item.factoryType | changefactoryType}}
							</view>
							<view class="subsidyMoney-main-content-li-cen-top-right font_blod">
								<text v-if="item.factoryType == 4"
									class="subsidyMoney-main-content-li-cen-top-right-txt2">-{{item.factoryMoney}}</text>
								<text v-else class="subsidyMoney-main-content-li-cen-top-right-txt1">+{{item.factoryMoney}}</text>
							</view>
						</view>
						<view class="subsidyMoney-main-content-li-cen-btm">
							<view class="subsidyMoney-main-content-li-cen-btm-left">
								{{item.createTime}}
							</view>
							<view class="subsidyMoney-main-content-li-cen-btm-right">
								余额 {{item.factoryBalance}}
							</view>
						</view>
					</view>
					<view class="subsidyMoney-main-content-li-right">
						<image class="subsidyMoney-main-content-li-right-img" src="https://www.zzzsyh.com/applets/agent/agent/right-two.png"
							mode=""></image>
					</view>
				</view>
			</view>
			<view class="" v-else>
				<view class="yPopNone">
					<image class="yPopNoneImg" src="https://www.zzzsyh.com/applets/agent/factory/23.png" mode="">
					</image>
					<view class="yPopNoneTxt">
						暂无明细~
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				factoryId: uni.getStorageSync('id_factory'),
				factoryBalance: '',
				list: []
			}
		},
		mounted() {
			// 获取厂家质保押金明细
			this.getFactoryMoneyDetails()
		},
		methods: {
			// 跳转详情
			cli_li (item, index) {
				let type = item.factoryType
				if (type == 4) {
					uni.navigateTo({
						url: '/pages/manufacturers/subsidyMoneyDetails/subsidyMoneyDetails?id=' + item.factoryOrderNum
					})
				}else {
					uni.navigateTo({
						url: '/pages/manufacturers/topUpDetails/topUpDetails?' + `type=${item.factoryType}&money=${item.factoryMoney}&time=${item.createTime}`
					})
				}
			},
			// 跳转到充值
			cli_topUp() {
				uni.navigateTo({
					url: '/pages/manufacturers/paymoney/paymoney'
				})
			},
			// 获取厂家质保押金明细
			getFactoryMoneyDetails() {
				uni.request({
					url: allapi.getFactoryMoneyDetails,
					data: {
						factoryId: this.factoryId,
						classify: 2
					},
					success: (res) => {
						console.log(res);
						let dat = res.data.data
						this.factoryBalance = dat.factoryBalance
						this.list = dat.balanceDetailsList
					}
				})
			}
		},
		filters: {
			changefactoryType(val) {
				if (val == 1) {
					return '厂家充值'
				} else if (val == 2) {
					return '后台充值'
				} else if (val == 3) {
					return '余额充值补充'
				} else if (val == 4) {
					return '补助金扣除'
				}
			}
		}
	}
</script>

<style scoped>
	.subsidyMoney {
		position: absolute;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
		background: #FFFFFF;
		display: flex;
		flex-direction: column;
	}

	.subsidyMoney-head {
		height: 302rpx;
		background-image: url('https://www.zzzsyh.com/applets/agent/factory/11.png');
		background-size: 100%;
		background-repeat: no-repeat;
		padding-top: 0.1rpx;
	}

	.subsidyMoney-head-title1 {
		margin-left: 70rpx;
		margin-top: 44rpx;
		font-size: 32rpx;
		color: #342100;
		line-height: 44rpx;
	}

	.subsidyMoney-head-title2 {
		margin-top: 16rpx;
		margin-left: 70rpx;
		line-height: 98rpx;
		display: flex;
		align-items: center;
	}

	.subsidyMoney-head-title2-txt1 {
		font-size: 72rpx;
		font-weight: bold;
		color: #342100;
	}

	.subsidyMoney-head-title2-txt2 {
		width: 104rpx;
		height: 56rpx;
		line-height: 56rpx;
		text-align: center;
		background: #342100;
		border-radius: 8rpx;
		font-size: 28rpx;
		color: #FBAF18;
		display: block;
		margin-left: 48rpx;
	}

	.subsidyMoney-main {
		flex: 1;
		margin-top: -40rpx;
		border-top-left-radius: 32rpx;
		border-top-right-radius: 32rpx;
		background: #FFFFFF;
		padding: 24rpx 26rpx;
		display: flex;
		flex-direction: column;
		overflow: auto;
	}

	.subsidyMoney-main-title {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.subsidyMoney-main-title-left {
		display: flex;
		align-items: center;
	}

	.subsidyMoney-main-title-txt1 {
		width: 10rpx;
		height: 34rpx;
		background: #5DD4D6;
		border-radius: 5rpx;
		display: block;
	}

	.subsidyMoney-main-title-txt2 {
		font-size: 32rpx;
		color: #333333;
		margin-left: 24rpx;
	}

	.subsidyMoney-main-title-txt3 {
		font-size: 24rpx;
		color: #666666;
	}

	.subsidyMoney-main-content {
		flex: 1;
		margin-top: 26rpx;
		overflow: auto;
	}

	.subsidyMoney-main-content-li {
		height: 128rpx;
		display: flex;
		align-items: center;
		border-bottom: 1rpx solid #EEEEEE;
	}

	.subsidyMoney-main-content-li-left-img {
		width: 48rpx;
		height: 48rpx;
	}

	.subsidyMoney-main-content-li-right-img {
		width: 32rpx;
		height: 32rpx;
	}

	.subsidyMoney-main-content-li-cen {
		flex: 1;
		margin: 0 24rpx;
	}

	.subsidyMoney-main-content-li-cen-top {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.subsidyMoney-main-content-li-cen-btm {
		display: flex;
		margin-top: 16rpx;
		align-items: center;
		justify-content: space-between;
	}

	.subsidyMoney-main-content-li-cen-top-left {
		font-size: 28rpx;
		color: #333333;
	}

	.subsidyMoney-main-content-li-cen-top-right {
		font-size: 32rpx;
		color: #333333;
	}

	.subsidyMoney-main-content-li-cen-top-right-txt1 {
		color: #EF691C;
	}

	.subsidyMoney-main-content-li-cen-top-right-txt2 {
		color: #333333;
	}

	.subsidyMoney-main-content-li-cen-btm-left {
		font-size: 24rpx;
		color: #666666;
	}

	.subsidyMoney-main-content-li-cen-btm-right {
		font-size: 24rpx;
		color: #666666;
	}
</style>
